package main

import (
	"fmt"
	"os"
)

func main(){
	fileName := "example.txt"
	content := []byte("Hello there!")

	// write into file
	err := os.WriteFile(fileName,content,0644)
	if err != nil {
		fmt.Println("os writeFile err:",err)
		return
	}
	fmt.Printf("Wrote '%s' to '%s' \n",string(content),fileName)

	// read from file
	data,err := os.ReadFile(fileName)
	if err != nil {
		fmt.Println("os readFile err:",err)
		return
	}
	fmt.Printf("Read from %s: '%s'\n", fileName, string(data))

	// clean file
	if err := os.Remove(fileName);err != nil {
		fmt.Println("os remove err:",err)
	}

}